<template>
  <div>
    <div class="list-table">
      <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
        <el-tab-pane v-for="(item) in investGroupList" :key="item.id" :label="item.dealName" :name="item.id" />
      </el-tabs>
      <bfInvestGroupForm v-if="isShowPage" ref="bfInvestGroupForm" />
    </div>
  </div>
</template>

<script>

import { getInvestGroupByCompanyId } from '@/api/bf/investGroup/bfInvestGroup'
import bfInvestGroupForm from '@/views/bf/investGroup/bfInvestGroupForm.vue'
export default {
  components: {
    bfInvestGroupForm
  },
  data() {
    return {
      activeName: '',
      investGroupList: [],
      isShowPage: false
    }
  },
  mounted() {
    // 获取相关子基金作为页签
    getInvestGroupByCompanyId(this.$route.query.companyId).then(res => {
      this.investGroupList = res.data
      this.activeName = this.investGroupList[0].id
      this.handleClick({ name: this.activeName })
    })
  },
  methods: {
    handleClick(tab, event) {
      console.log(tab, event)
      this.isShowPage = false
      this.isShowPage = true
      this.$nextTick(() => {
        this.$refs.bfInvestGroupForm.init({ id: tab.name })
      })
    }
  }
}
</script>

<style scoped>

</style>
